package com.hfzy.ihk.common.core.elasticsearch.base;

import com.alibaba.fastjson.JSON;
import com.hfzy.ihk.common.core.elasticsearch.ElasticsearchLocalCache;
import com.hfzy.ihk.common.core.elasticsearch.ElasticsearchOperation;
import com.hfzy.ihk.common.core.elasticsearch.OperationErrorMsgBiz;
import com.hfzy.ihk.common.core.elasticsearch.entity.OperationErrorMsg;
import com.hfzy.ihk.common.core.elasticsearch.repository.common.OperationErrorMsgRepository;
import com.hfzy.ihk.common.util.string.StringUtil;
import org.elasticsearch.common.UUIDs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Lazy;

import java.util.Date;

/**
 * Created by Administrator on 2018/7/18.
 *
 * @author wws
 */
@DependsOn("operationErrorMsgBiz")
public abstract class CommonTableOperationHandler extends AbstractTableOperationHandler {

    private static final Logger logger = LoggerFactory.getLogger(CommonTableOperationHandler.class);

    @Autowired
    private OperationErrorMsgBiz operationErrorMsgBiz;

    /***
     *
     * 表操作失败的处理
     * */
    @Override
    protected void handleError(ElasticsearchOperation elasticsearchOperation, Exception e) {

        if(elasticsearchOperation.isFromJobRun()){
            return;
        }

        logger.error("处理操作错误：",e);

        operationErrorMsgBiz.dealElasticsearchOperation(elasticsearchOperation,e);
    }

}
